package cn.net.gexing.dao.impl;


import java.util.List;

import org.apache.ibatis.session.RowBounds;
import org.mybatis.spring.SqlSessionTemplate;

import cn.net.gexing.dao.PersonDAO;
import cn.net.gexing.model.Article;


public class PersonDAOImpl implements PersonDAO {

	public SqlSessionTemplate sqlSessionTemplate;
	
	
	public void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate) {
		this.sqlSessionTemplate = sqlSessionTemplate;
	}

	public Article getPersonById(int id) {
		Article person=(Article)this.sqlSessionTemplate.selectOne("person.getPersonById", id);
		return person;
	}

	public int insert(Article person) {
		int flag=this.sqlSessionTemplate.insert("insertvalues", person);
		return flag;
	}

	@Override
	public List<Article> getArticleByCount(int count) {
		RowBounds row = new RowBounds(0, count);
		List<Article> list = (List<Article>) this.sqlSessionTemplate.selectList("person.getArticleByCount", "", row);
		return list;
	}

}
